package com.hisan.freeride.home.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;

import com.hisan.freeride.R;
import com.hisan.freeride.common.base.AppConfig;
import com.hisan.freeride.common.base.BaseActivity;
import com.hisan.freeride.common.callback.DialogCallback;
import com.hisan.freeride.common.utils.CollectionUtils;
import com.hisan.freeride.common.view.SyLinearLayoutManager;
import com.hisan.freeride.databinding.CommentMessageBinding;
import com.hisan.freeride.home.adapter.Welfare_Message_ListAdapter;
import com.hisan.freeride.home.model.WelfareMessage;
import com.lzy.ninegrid.ImageInfo;
import com.lzy.ninegrid.preview.NineGridViewClickAdapter;
import com.lzy.okgo.OkGo;

import java.util.ArrayList;

/**
 * 创建时间 : 2017/6/10
 * 创建人：yangyingqi
 * 公司：嘉善和盛网络有限公司
 * 备注：我的评价详情页面
 */
public class CommentMessageActivity extends BaseActivity<CommentMessageBinding> {
    private Welfare_Message_ListAdapter welfare_message_listAdapter;
    private int did;
    private int pageNumber=1;
    private WelfareMessage wrelease;

    @Override
    protected int getLayoutId() {
        return R.layout.comment_message;
    }

    @Override
    protected void initView() {
        Bundle bundle=getIntent().getExtras();
        if(!CollectionUtils.isNullOrEmpty(bundle)){
            did=bundle.getInt("id");
        }
        mBinding.setStateModel(mStateModel);
        mBinding.nineGrid.setSingleImageSize(200);
        mBinding.rv.setLayoutManager(new SyLinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        welfare_message_listAdapter=new Welfare_Message_ListAdapter(new ArrayList<>(0));
        mBinding.rv.setAdapter(welfare_message_listAdapter);
    }

    @Override
    protected void initEvent() {
        mBinding.topBack.setOnClickListener(v -> finishActivity(true));
//        mBinding.owner.setOnClickListener(v -> {
//            if (!CollectionUtils.isNullOrEmpty(wrelease)){
//                Bundle bundle=new Bundle();
//                bundle.putInt("driver_id",wrelease.getReply().getDriver_id());
//                startActivityForResult(LoveCartDetailsActivity.class,0,bundle,true);
//            }
//        });
    }

    @Override
    protected void loadData(boolean isRefresh) {
//        OkGo.<WelfareMessage>get(AppConfig.Getreply)
//                .tag(this)
//                .params("id",did)
//                .params("pageNumber",pageNumber)
//                .params("pageSize",20)
//                .execute(new DialogCallback<WelfareMessage>(this) {
//                    @Override
//                    public void onSuccess(com.lzy.okgo.model.Response<WelfareMessage> response) {
//                        super.onSuccess(response);
//                        if (!CollectionUtils.isNullOrEmpty(response.body())){
//                            showData();
//                            if (isOk(response)){
//                                wrelease=response.body();
//                                mBinding.setWelfareMessage(wrelease);
//                                if (!CollectionUtils.isNullOrEmpty(wrelease.getReply().getAlbum())) {
//                                    ArrayList<ImageInfo> imageInfo = new ArrayList<>();
//                                    for (String iamge : wrelease.getReply().getAlbum()) {
//                                        ImageInfo info = new ImageInfo();
//                                        info.setThumbnailUrl(iamge);
//                                        info.setBigImageUrl(iamge);
//                                        imageInfo.add(info);
//                                    }
//                                    if (wrelease.getReply().getZanmark()>0){
//                                        mBinding.zan.setImageResource(R.mipmap.zan_fill);
//                                    }else{
//                                        mBinding.zan.setImageResource(R.mipmap.zan);
//                                    }
//                                    mBinding.nineGrid.setAdapter(new NineGridViewClickAdapter(CommentMessageActivity.this, imageInfo));
//                                }
//                                if (!CollectionUtils.isNullOrEmpty(wrelease.getList())) {
//                                    welfare_message_listAdapter.setNewData(wrelease.getList());
//                                }
//                            }else {
//                                showErrorView(response.code());
//                            }
//                        }else {
//                            noData();
//                        }
//                    }
//
//                    @Override
//                    public void onError(com.lzy.okgo.model.Response<WelfareMessage> response) {
//                        super.onError(response);
//                        showErrorView(response.code());
//                    }
//                });
    }


}
